From dcc63e79155b1df7793b3fecccf1e395298c8ee7 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Wed, 16 Apr 2003 12:44:16 +0000 Subject: [PATCH] bitkeeper revision 1.172 (3e9d5020hc5RUkx3ArM71EjZ_UUbgw) Many files: Fixed event masking so that events can be individually masked. Fixed Xenolinux config/build system. --- xen/arch/i386/entry.S | 18 ++++--- xen/common/keyhandler.c | 4 +- xen/include/hypervisor-ifs/hypervisor-if.h | 18 +++++-- .../arch/xeno/config.in | 2 + .../arch/xeno/defconfig | 49 +++++++++++++++-- .../arch/xeno/kernel/entry.S | 15 +++--- .../arch/xeno/kernel/hypervisor.c | 25 +++++---- .../include/asm-xeno/system.h | 52 ++++++++++++------- 8 files changed, 129 insertions(+), 54 deletions(-) diff --git a/xen/arch/i386/entry.S b/xen/arch/i386/entry.S index ede1fe45e5..3f9c8c99bd 100644 --- a/xen/arch/i386/entry.S +++ b/xen/arch/i386/entry.S @@ -115,7 +115,7 @@ FAILSAFE_ADDR = 32 /* Offsets in shared_info_t */ EVENTS = 0 -EVENTS_ENABLE = 4 +EVENTS_MASK = 4 /* Offsets in guest_trap_bounce */ GTB_ERROR_CODE = 0 @@ -297,13 +297,15 @@ test_all_events: jnz process_hyp_events /*test_guest_events:*/ movl SHARED_INFO(%ebx),%eax - test %ecx,EVENTS(%eax) - jz restore_all - test %ecx,EVENTS_ENABLE(%eax) - jz restore_all - /* Prevent unnecessary reentry of event callback (stack overflow!) */ - xorl %ecx,%ecx - movl %ecx,EVENTS_ENABLE(%eax) + shl $31,%ecx # %ecx = EVENTS_MASTER_ENABLE_MASK + test %ecx,EVENTS_MASK(%eax) + jz restore_all # only notify if master switch enabled + movl EVENTS(%eax),%ecx + andl EVENTS_MASK(%eax),%ecx + jz restore_all # skip if no events to deliver + notl %ecx + btrl $31,%ecx # NB. We clear all events that are + andl %ecx,EVENTS_MASK(%eax) # being delivered + master enable. /*process_guest_events:*/ mov PROCESSOR(%ebx),%edx shl $4,%edx # sizeof(guest_trap_bounce) == 16 diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 93b9132a7f..261e6fbb79 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -103,8 +103,8 @@ void do_task_queues(u_char key, void *dev_id, struct pt_regs *regs) task_states[p->state], p->hyp_events); s = p->shared_info; if(!is_idle_task(p)) { - printk("Guest: events = %08lx, event_enable = %08lx\n", - s->events, s->events_enable); + printk("Guest: events = %08lx, events_mask = %08lx\n", + s->events, s->events_mask); printk("Notifying guest...\n"); set_bit(_EVENT_DEBUG, &s->events); } diff --git a/xen/include/hypervisor-ifs/hypervisor-if.h b/xen/include/hypervisor-ifs/hypervisor-if.h index 5d23765aca..6abf2c2222 100644 --- a/xen/include/hypervisor-ifs/hypervisor-if.h +++ b/xen/include/hypervisor-ifs/hypervisor-if.h @@ -131,6 +131,13 @@ #define PGEXT_CMD_SHIFT 8 +/* + * Master "switch" for enabling/disabling event delivery. + */ +#define EVENTS_MASTER_ENABLE_MASK 0x80000000UL +#define EVENTS_MASTER_ENABLE_BIT 31 + + #ifndef __ASSEMBLY__ #include "network.h" @@ -173,12 +180,13 @@ typedef struct shared_info_st { /* Bitmask of outstanding event notifications hypervisor -> guest OS. */ unsigned long events; /* - * Hypervisor will only signal event delivery via the "callback - * exception" when this value is non-zero. Hypervisor clears this when - * notiying the guest OS -- this prevents unbounded reentrancy and - * stack overflow (in this way, acts as an interrupt-enable flag). + * Hypervisor will only signal event delivery via the "callback exception" + * when a pending event is not masked. The mask also contains a "master + * enable" which prevents any event delivery. This mask can be used to + * prevent unbounded reentrancy and stack overflow (in this way, acts as a + * kind of interrupt-enable flag). */ - unsigned long events_enable; + unsigned long events_mask; /* * Time: The following abstractions are exposed: System Time, Clock Time, diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/config.in b/xenolinux-2.4.21-pre4-sparse/arch/xeno/config.in index a12a1ec5c0..7dd6b1c985 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/config.in +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/config.in @@ -125,3 +125,5 @@ if [ "$CONFIG_DEBUG_KERNEL" != "n" ]; then fi endmenu + +source lib/Config.in \ No newline at end of file diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig b/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig index 96ede4cd2e..c9e4e1a4f7 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig @@ -113,7 +113,7 @@ CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_NBD=y CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=4096 -# CONFIG_BLK_DEV_INITRD is not set +CONFIG_BLK_DEV_INITRD=y CONFIG_XENOLINUX_BLOCK=y # @@ -286,10 +286,11 @@ CONFIG_JBD=y # CONFIG_FAT_FS is not set # CONFIG_CRAMFS is not set # CONFIG_TMPFS is not set -# CONFIG_RAMFS is not set +CONFIG_RAMFS=y CONFIG_ISO9660_FS=y CONFIG_JOLIET=y CONFIG_ZISOFS=y +CONFIG_ZISOFS_FS=y # CONFIG_MINIX_FS is not set # CONFIG_VXFS_FS is not set # CONFIG_NTFS_FS is not set @@ -301,6 +302,47 @@ CONFIG_EXT2_FS=y # CONFIG_UDF_FS is not set # CONFIG_UFS_FS is not set +# Skanky NLS stuff +CONFIG_NLS_DEFAULT="iso8559-1" +CONFIG_NLS_CODEPAGE_437=n +CONFIG_NLS_CODEPAGE_737=n +CONFIG_NLS_CODEPAGE_775=n +CONFIG_NLS_CODEPAGE_850=n +CONFIG_NLS_CODEPAGE_852=n +CONFIG_NLS_CODEPAGE_855=n +CONFIG_NLS_CODEPAGE_857=n +CONFIG_NLS_CODEPAGE_860=n +CONFIG_NLS_CODEPAGE_861=n +CONFIG_NLS_CODEPAGE_862=n +CONFIG_NLS_CODEPAGE_863=n +CONFIG_NLS_CODEPAGE_864=n +CONFIG_NLS_CODEPAGE_865=n +CONFIG_NLS_CODEPAGE_866=n +CONFIG_NLS_CODEPAGE_869=n +CONFIG_NLS_CODEPAGE_936=n +CONFIG_NLS_CODEPAGE_950=n +CONFIG_NLS_CODEPAGE_932=n +CONFIG_NLS_CODEPAGE_949=n +CONFIG_NLS_CODEPAGE_874=n +CONFIG_NLS_ISO8859_8=n +CONFIG_NLS_CODEPAGE_1250=n +CONFIG_NLS_CODEPAGE_1251=n +CONFIG_NLS_ISO8859_1=n +CONFIG_NLS_ISO8859_2=n +CONFIG_NLS_ISO8859_3=n +CONFIG_NLS_ISO8859_4=n +CONFIG_NLS_ISO8859_5=n +CONFIG_NLS_ISO8859_6=n +CONFIG_NLS_ISO8859_7=n +CONFIG_NLS_ISO8859_9=n +CONFIG_NLS_ISO8859_13=n +CONFIG_NLS_ISO8859_14=n +CONFIG_NLS_ISO8859_15=n +CONFIG_NLS_KOI8_R=n +CONFIG_NLS_KOI8_U=n +CONFIG_NLS_UTF8=n + + # # Network File Systems # @@ -406,5 +448,4 @@ CONFIG_KALLSYMS=y # Library routines # CONFIG_ZLIB_INFLATE=y - - +CONFIG_ZLIB_DEFLATE=n diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/entry.S b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/entry.S index 20ae79e50e..0250f5e11b 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/entry.S +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/entry.S @@ -210,15 +210,14 @@ ENTRY(system_call) movl %eax,EAX(%esp) # save the return value ENTRY(ret_from_sys_call) movl SYMBOL_NAME(HYPERVISOR_shared_info),%esi - xorl %eax,%eax - movl %eax,4(%esi) # need_resched and signals atomic test + btrl $EVENTS_MASTER_ENABLE_BIT,4(%esi) # make tests atomic ret_syscall_tests: cmpl $0,need_resched(%ebx) jne reschedule cmpl $0,sigpending(%ebx) je safesti # ensure need_resched updates are seen signal_return: - btsl %eax,4(%esi) # reenable event callbacks + btsl $EVENTS_MASTER_ENABLE_BIT,4(%esi) # reenable event callbacks movl %esp,%eax xorl %edx,%edx call SYMBOL_NAME(do_signal) @@ -255,8 +254,8 @@ ret_from_exception: ALIGN reschedule: - btsl %eax,4(%esi) # reenable event callbacks - call SYMBOL_NAME(schedule) # test + btsl $EVENTS_MASTER_ENABLE_BIT,4(%esi) # reenable event callbacks + call SYMBOL_NAME(schedule) # test jmp ret_from_sys_call ENTRY(divide_error) @@ -319,12 +318,12 @@ ENTRY(hypervisor_callback) movb CS(%esp),%cl test $2,%cl # slow return to ring 2 or 3 jne ret_syscall_tests -safesti:btsl %eax,4(%esi) # reenable event callbacks +safesti:btsl $EVENTS_MASTER_ENABLE_BIT,4(%esi) # reenable event callbacks scrit: /**** START OF CRITICAL REGION ****/ cmpl %eax,(%esi) jne 14f # process more events if necessary... RESTORE_ALL -14: btrl %eax,4(%esi) +14: btrl $EVENTS_MASTER_ENABLE_BIT,4(%esi) jmp 11b ecrit: /**** END OF CRITICAL REGION ****/ # [How we do the fixup]. We want to merge the current stack frame with the @@ -366,7 +365,7 @@ critical_fixup_table: .byte 0x20 # pop %es .byte 0x24,0x24,0x24 # add $4,%esp .byte 0x28 # iret - .byte 0x00,0x00,0x00,0x00 # btrl %eax,4(%esi) + .byte 0x00,0x00,0x00,0x00,0x00 # btrl $31,4(%esi) .byte 0x00,0x00 # jmp 11b # Hypervisor uses this for application faults while it executes. diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/hypervisor.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/hypervisor.c index 68670daa8c..3f414e9876 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/hypervisor.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/kernel/hypervisor.c @@ -27,8 +27,8 @@ void do_hypervisor_callback(struct pt_regs *regs) do { /* Specialised local_irq_save(). */ - flags = shared->events_enable; - shared->events_enable = 0; + flags = test_and_clear_bit(EVENTS_MASTER_ENABLE_BIT, + &shared->events_mask); barrier(); events = xchg(&shared->events, 0); @@ -50,7 +50,7 @@ void do_hypervisor_callback(struct pt_regs *regs) : "eax", "ecx", "edx", "memory" ); /* Specialised local_irq_restore(). */ - shared->events_enable = flags; + if ( flags ) set_bit(EVENTS_MASTER_ENABLE_BIT, &shared->events_mask); barrier(); } while ( shared->events ); @@ -62,25 +62,25 @@ void do_hypervisor_callback(struct pt_regs *regs) * Define interface to generic handling in irq.c */ -static unsigned int startup_hypervisor_event(unsigned int irq) -{ - set_bit(irq, &event_mask); - return 0; -} - static void shutdown_hypervisor_event(unsigned int irq) { clear_bit(irq, &event_mask); + clear_bit(irq, &HYPERVISOR_shared_info->events_mask); } static void enable_hypervisor_event(unsigned int irq) { set_bit(irq, &event_mask); + set_bit(irq, &HYPERVISOR_shared_info->events_mask); + if ( test_bit(EVENTS_MASTER_ENABLE_BIT, + &HYPERVISOR_shared_info->events_mask) ) + do_hypervisor_callback(NULL); } static void disable_hypervisor_event(unsigned int irq) { clear_bit(irq, &event_mask); + clear_bit(irq, &HYPERVISOR_shared_info->events_mask); } static void ack_hypervisor_event(unsigned int irq) @@ -90,6 +90,13 @@ static void ack_hypervisor_event(unsigned int irq) printk("Unexpected hypervisor event %d\n", irq); atomic_inc(&irq_err_count); } + set_bit(irq, &HYPERVISOR_shared_info->events_mask); +} + +static unsigned int startup_hypervisor_event(unsigned int irq) +{ + enable_hypervisor_event(irq); + return 0; } static void end_hypervisor_event(unsigned int irq) diff --git a/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/system.h b/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/system.h index e318716a66..387ac0fdad 100644 --- a/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/system.h +++ b/xenolinux-2.4.21-pre4-sparse/include/asm-xeno/system.h @@ -312,31 +312,47 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, #define set_mb(var, value) do { xchg(&var, value); } while (0) #define set_wmb(var, value) do { var = value; wmb(); } while (0) -/* interrupt control.. */ -#define __save_flags(x) ((x) = HYPERVISOR_shared_info->events_enable); barrier() -#define __restore_flags(x) \ -do { \ - shared_info_t *_shared = HYPERVISOR_shared_info; \ - _shared->events_enable = (x); \ - barrier(); \ - if ( unlikely(_shared->events) && (x) ) do_hypervisor_callback(NULL); \ + +#define __save_flags(x) \ +do { \ + (x) = test_bit(EVENTS_MASTER_ENABLE_BIT, \ + &HYPERVISOR_shared_info->events_mask); \ + barrier(); \ +} while (0) + +#define __restore_flags(x) \ +do { \ + shared_info_t *_shared = HYPERVISOR_shared_info; \ + if (x) set_bit(EVENTS_MASTER_ENABLE_BIT, &_shared->events_mask); \ + barrier(); \ + if ( unlikely(_shared->events) && (x) ) do_hypervisor_callback(NULL); \ +} while (0) + +#define __cli() \ +do { \ + clear_bit(EVENTS_MASTER_ENABLE_BIT, &HYPERVISOR_shared_info->events_mask);\ + barrier(); \ } while (0) -#define __cli() (HYPERVISOR_shared_info->events_enable = 0); barrier() -#define __sti() \ -do { \ - shared_info_t *_shared = HYPERVISOR_shared_info; \ - _shared->events_enable = 1; \ - barrier(); \ - if ( unlikely(_shared->events) ) do_hypervisor_callback(NULL); \ + +#define __sti() \ +do { \ + shared_info_t *_shared = HYPERVISOR_shared_info; \ + set_bit(EVENTS_MASTER_ENABLE_BIT, &_shared->events_mask); \ + barrier(); \ + if ( unlikely(_shared->events) ) do_hypervisor_callback(NULL); \ } while (0) + #define safe_halt() ((void)0) #define __save_and_cli(x) do { __save_flags(x); __cli(); } while(0); #define __save_and_sti(x) do { __save_flags(x); __sti(); } while(0); -/* For spinlocks etc */ -//XXX#define local_irq_set(x) __save_and_sti(x) -#define local_irq_save(x) ((x) = HYPERVISOR_shared_info->events_enable); (HYPERVISOR_shared_info->events_enable = 0); barrier() +#define local_irq_save(x) \ +do { \ + (x) = test_and_clear_bit(EVENTS_MASTER_ENABLE_BIT, \ + &HYPERVISOR_shared_info->events_mask); \ + barrier(); \ +} while (0) #define local_irq_restore(x) __restore_flags(x) #define local_irq_disable() __cli() #define local_irq_enable() __sti() -- 2.30.2